package com.ocom.amqp.core;

import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

public class AmqpBasicBeanDefinition implements ImportBeanDefinitionRegistrar {

    /**
     * 将 {@link AmqpBasicBeanProcessor} 注册到容器中， 用于在每个实例创建前检测类似
     * 是否是AMQPBasic 支持的封装组件
     *
     * @param importingClassMetadata
     * @param registry
     */
    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        //注册组件到spring 容器中
        AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(AmqpBasicBeanProcessor
                .class).getBeanDefinition();
        registry.registerBeanDefinition("amqpBasicBeanProcessor", beanDefinition);
    }


}
